package org.openit.portail.dao.impl;

import java.util.List;

import org.hibernate.SessionFactory;
import org.openit.portail.dao.ProfilDao;
import org.openit.portail.model.Profil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;


@Repository
@Transactional
public class ProfilDaoImpl implements ProfilDao {

	private SessionFactory sessionFactory;

	@SuppressWarnings("unchecked")
	public List<Profil> findAll() {
		return sessionFactory.getCurrentSession().createQuery("from Profil").list();
	}

	@Autowired
	public void setSessionFactory(SessionFactory sessionFactory) {
		this.sessionFactory = sessionFactory;
	}

	
	public Profil get(Long id) {
		return (Profil) sessionFactory.getCurrentSession()
		.createQuery("from Profil profil  where profil.id = :id")
		.setLong("id", id).uniqueResult();
	}

	

}
